NS BASIC Overview and FAQ
-------------------------

NS BASIC, an implementation of the well-known BASIC programming language, is
now available for the Newton. The product is aimed at the business,
educational and scientific marketplaces. 

Programs can be written directly on the Newton: no host system is required.
The environment is completely interactive. A full complement of functions and
data types is provided. Handwritten input, windowing and checkboxes are
supported. Applications can create their own files or access built in system
information, such as Addresses, Notes and Calendar entries. 

The product includes a 150 page user manual which explains each of the
commands, statements and functions. Examples are provided throughout. Sample
code which can be downloaded is also provided. 

NS BASIC will appeal to users who have some exposure to the BASIC programming
language or wish to learn it. The implementation is similar to many of the
currently available versions of BASIC that run on other computer systems.
-------------------------------------------------------------------- 
NSBASIC FAQ: Jul 1, 1994

What is Basic?

Basic is probably the world's most widely used computer programming langauge.
Versions of it exist for virtually every make and model of computer. Simple
programming constructs such as FOR...NEXT and GOSUB provide an easy, quickly
learned syntax. Basic is usually implemented an interactive language,
allowing programmers to test their work as they go and easily modify and
debug their code. Basic has resisted all attempts at standardization: there
are numerous dialects in existance. It is widely used for business,
educational and scientific applications. 

What kind of Basic is this?

NS BASIC is a fully interactive implementation of Basic. As well as providing
the full instruction set, it has extensions to take advantage of the Newton
environment. If you don't find the specific version of a function or
statement you may have used in another Basic, there is almost certainly an
equivilent in NS BASIC.

What do I need to program in NS BASIC?

NSB can be programmed directly on the Newton without requiring a host system.
Popups provide quick access to many commands and statements; other code can
be input using the on screen keyboard or via handwritten input. Programs can
also be downloaded via a serial port, or edited from a PC or Mac using a
terminal emulator tied in through the serial port. 

What data types are supported?

Integers, reals, floating point, strings, arrays and frames. A frame is a
list of field names, each with a value that can be any of the data types
(including another frame).

Can I create files?

Yes. For example, the statement CREATE CH,"MYFILE",NAME will create a file
named MYFILE, indexed by NAME and open on channel CH. 

Can I accept handwritten input?

Yes. The statement HWINPUT X will put up an edit box. The text the user
enters will be returned in X. Options on this statement include putting up a
prompt and a picklist of potential input values. 

Is it a substitute for NTK?

No. The NTK (Newton Tool Kit) is still the development environment of choice
for serious application development. However, since the licence fee is $895,
a powerful Macintosh is required as a development platform and an experienced
and skilled programmer need a few months of work with to become full
productive, it is not for everyone. NS BASIC is well suited for the casual
programmer who needs to develop less complex applications. 

How much memory does it use?

NS BASIC itself requires 120K. A memory card is recommended for uses with the
original Newton Message pad, the upgraded Message Pad or the Message Pad 100.
Programs do not take up any additional internal memory while running, other
than space used for user variables. The code itself remains resident on the
card (except for the current statement) and does not impact internal memory.
Programs can therefore be of almost any size, subject to space available on
the card. The CHAIN statement can be used to segment programs.

Can I access system information?

Yes. For example, the following statement outputs the user's name from the
internal settings.

PRINT getglobals().userconfiguration.name 

Furthermore, it is possible to access the system information, such as the
Notepad. Here's a short program that creates a note: 

0010 rem write to notepad
0020 open ch,"notes",timestamp
0030 LET n={data:[{}]}
0040 LET n.viewstationery='paperroll
0050 LET n.height=100
0070 LET n.data[0].viewstationery='para
0080 LET n.data[0].viewbounds={left:0, right:200, top:0, bottom:100} 0090 LET
n.data[0].text="This note was created by NS BASIC" 0095 LET
n.data[0].viewfont=getglobals().userconfiguration.userfont 0100 LET
n.timestamp=time()
0110 put ch,n

Can I program windows and checkboxes?

Yes. Windows are passive boxes that hold text. You can define the bounds, the
boundary, the pattern for the boundary, the fill pattern and the text font,
style and size.

A checkbox is a window that causes a GOTO LineNumber to be executed when it
is tapped. With this, event driven programs can be created. 

Can I access other applications?

Yes. It is even possible to pass information to some other applications as
well. For example, to pass an array of numbers to Pelican Software's QChart
to product a graph, use the following code: 

0010 LET a=[1,3,6,2,4]
0020 LET getroot().|qf_qchart:donv|.ddxfrom='|basic:nsbasic| 0030 LET
x:=getroot().|qf_qchart:donv|:ddxscript(1,5,a,nil) 

The Qchart application will automatically open and produce the graph. 

Does it come with a manual?

Yes. An approximately 150 page manual, (spiral bound so it lies flat)
provides a complete description of the various commands, statements and
functions, together with examples for each one. The manual is about the same
size as the Newton, so it's easy to carry along with you. 

Can I distribute applications I write to other users? 

Yes, providing they have NS BASIC on their Newtons. Programs can be easily
uploaded and downloaded via a serial port. 

Can I program it using a regular keyboard? 

Yes, either from a Macintosh or DOS or Windows PC. All charactert input and
output is redirected through your host PC, so it's easy to work directly
using your PC's keyboard and screen.

How fast is it?

NS BASIC is an interpretive language. However, since interpretation is done
as statements are entered, not at run time, performance is optimized.
Statements take varying amounts of time to execute: a simple FOR/NEXT loop
executes at the rate of approximately 26 statements per second on an MP/100.
Advantages of interpreters include the ability to examine and change code in
the middle of execution and rapid development. 
